//
//  ViewController.m
//  10505颜色生成
//
//  Created by student on 16/2/20.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField1;
@property (weak, nonatomic) IBOutlet UITextField *textField2;
@property (weak, nonatomic) IBOutlet UITextField *textField3;
@property (weak, nonatomic) IBOutlet UIView *view1;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view1.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:1];
  
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)colorChanged:(UISlider *)sender {
    int value =sender.value;
    switch (sender.tag) {
        case 0:
            self.textField1.text=[NSString stringWithFormat:@"%i",value];
            break;
        case 1:
            self.textField2.text=[NSString stringWithFormat:@"%i",value];
            break;
        case 2:
            self.textField3.text=[NSString stringWithFormat:@"%i",value];
            break;
        default:
            break;
    }
      self.view1.backgroundColor=[UIColor colorWithRed:[self.textField1.text intValue]/255.0 green:[self.textField2.text intValue]/255.0 blue:[self.textField3.text intValue]/255.0 alpha:1.0];
}

@end
